SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_StoreBest]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_StoreBest](
	[n4StoreNo] [int] NOT NULL,
	[strManagerName] [nvarchar](50) NOT NULL,
	[dtCreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_TB_StoreBest] PRIMARY KEY CLUSTERED 
(
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_StoreBest]') AND name = N'IX_TB_StoreBest_dtCreateDate')
CREATE NONCLUSTERED INDEX [IX_TB_StoreBest_dtCreateDate] ON [dbo].[TB_StoreBest] 
(
	[dtCreateDate] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_Store](
	[n4StoreNo] [int] IDENTITY(1,1) NOT NULL,
	[strUserID] [varchar](50) NOT NULL,
	[IsActive] [char](1) NOT NULL,
	[strStoreName] [nvarchar](100) NULL,
	[strCompanyNo] [varchar](30) NULL,
	[strPhone] [varchar](30) NULL,
	[strPost] [varchar](10) NULL,
	[strAddress] [nvarchar](200) NULL,
	[strCityName] [nvarchar](10) NULL,
	[IsTakeout] [char](1) NULL,
	[strTakeout] [nvarchar](50) NULL,
	[IsParking] [char](1) NULL,
	[strParking] [nvarchar](50) NULL,
	[strStoreSize] [varchar](50) NULL,
	[strOpenDate] [varchar](20) NULL,
	[strOpenTime] [varchar](50) NULL,
	[strPointX] [varchar](30) NULL,
	[strPointY] [varchar](30) NULL,
	[strDescription] [nvarchar](2000) NULL,
	[dtCreateDate] [datetime] NOT NULL,
	[strManagerName] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_TB_Store] PRIMARY KEY CLUSTERED 
(
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND name = N'IX_TB_Store_dtCreateDate')
CREATE NONCLUSTERED INDEX [IX_TB_Store_dtCreateDate] ON [dbo].[TB_Store] 
(
	[dtCreateDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND name = N'IX_TB_Store_IsActive')
CREATE NONCLUSTERED INDEX [IX_TB_Store_IsActive] ON [dbo].[TB_Store] 
(
	[IsActive] ASC,
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND name = N'IX_TB_Store_strCityName')
CREATE NONCLUSTERED INDEX [IX_TB_Store_strCityName] ON [dbo].[TB_Store] 
(
	[IsActive] ASC,
	[strCityName] ASC,
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND name = N'IX_TB_Store_strStoreName')
CREATE NONCLUSTERED INDEX [IX_TB_Store_strStoreName] ON [dbo].[TB_Store] 
(
	[IsActive] ASC,
	[strStoreName] ASC,
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_Store]') AND name = N'UIX_TB_Store_strUserID')
CREATE UNIQUE NONCLUSTERED INDEX [UIX_TB_Store_strUserID] ON [dbo].[TB_Store] 
(
	[strUserID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_StoreImage]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_StoreImage](
	[n4StoreNo] [int] NOT NULL,
	[n4SeqNo] [int] IDENTITY(1,1) NOT NULL,
	[strImageURL] [varchar](200) NOT NULL,
	[strManagerName] [nvarchar](50) NOT NULL,
	[dtCreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_TB_StoreImage_1] PRIMARY KEY CLUSTERED 
(
	[n4StoreNo] ASC,
	[n4SeqNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END


CREATE TABLE [dbo].[TB_StoreMain](
	[n4StoreNo] [int] NOT NULL,
	[strTitleImageURL] [varchar](200) COLLATE Korean_Wansung_CI_AS NULL,
	[strTitleOverImageURL] [varchar](200) COLLATE Korean_Wansung_CI_AS NULL,
	[strImageURL] [varchar](200) COLLATE Korean_Wansung_CI_AS NULL,
	[dtCreateDate] [datetime] NULL,
	[strManagerName] [nvarchar](50) COLLATE Korean_Wansung_CI_AS NULL,
 CONSTRAINT [PK_TB_StoreMain_1] PRIMARY KEY CLUSTERED 
(
	[n4StoreNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]